// 引入 react 依赖
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Text, View, Image, TouchableOpacity, ImageBackground, ScrollView, NetInfo,InteractionManager } from 'react-native';

// 引入第三方依赖
import _ from 'lodash';
import pureRender from 'pure-render-decorator';

// antd 按需加载
import { } from '@ant-design/react-native';

// 引入 处理数据 所需文件
import { } from './module.js'

// 引入样式
import Styles from './style.js';

// 引入公用组件
import { Results } from '../../components/index.js'

// 引入工具包
import { press, size, ScreenWidth , defaultDataList,onEndReached,onRefresh ,concatDataList,defaultPage} from '../../util/utils.js'
class NetInfoScene extends Component {
	static propTypes = {

	}

	constructor(props) {
		super(props)
		this.state = {
			reach: null
		}
	}

	handleFirstConnectivityChange = (reach) => {
		// console.log('First change: ' + reach);
		this.setState({ reach })
		NetInfo.removeEventListener('change', this.handleFirstConnectivityChange);
	}

	componentWillMount() {
		NetInfo.fetch().done((reach) => {
			// console.log('Initial: ' + reach);
		});
		NetInfo.addEventListener('change', this.handleFirstConnectivityChange);
	}

	render() {
		const { children } = this.props
		const { reach } = this.state
		if (reach == 'none' || reach == 'unknown') {
			return (
				<View style={Styles.container} >
					<Result
						type="network"
					/>
				</View>
			)

		} else {
			return (
				<View style={Styles.container} >
					{children}
				</View>
			)
		}
	}
}

export default pureRender(NetInfoScene)
